package net.xdclass.user.model;

import java.util.Arrays;
import java.util.Date;

/** 邮件传输实体 */
public class MailDTO {
    /** 邮件发送者 */
    private String from;

    /** 邮件接受者，可能有多个 */
    private String[] to;

    /** 邮件主题 */
    private String subject;

    /** 抄送人 */
    private String cc;

    /** 邮件发送日期 */
    private Date sentDate;

    /** 邮件发送正文 */
    private String text;

    /** 附件名 */
    private String enclosureName;

    /** 附件地址 */
    private String filePath;

    /** 状态 */
    private String status;

    /** 错误消息 */
    private String err;

    public MailDTO(MailBuilder builder) {
        this.cc = builder.getCc();
        this.from = builder.getFrom();
        this.sentDate = builder.getSentDate();
        this.subject = builder.getSubject();
        this.text = builder.getText();
        this.to = builder.getTo();
        this.filePath = builder.getData();
        this.status = builder.getStatus();
        this.err = builder.getErr();
        this.enclosureName = builder.getEnclosureName();
    }

    public static class MailBuilder {
        /** 邮件发送者 */
        private String from;

        /** 邮件接受者，可能有多个 */
        private String[] to;

        /** 邮件主题 */
        private String subject;

        /** 抄送人 */
        private String cc;

        /** 邮件发送日期 */
        private Date sentDate;

        /** 邮件发送正文 */
        private String text;

        /** 附件名 */
        private String enclosureName;

        /** 附件地址 */
        private String filePath;

        /** 状态 */
        private String status;

        /** 错误消息 */
        private String err;

        public MailBuilder from(String from){
            this.from = from;
            return this;
        }

        public MailBuilder to (String... to){
            this.to = to;
            return this;
        }

        public MailBuilder subject(String subject){
            this.subject = subject;
            return this;
        }

        public MailBuilder cc(String cc){
            this.cc = cc;
            return this;
        }

        public MailBuilder date(Date sentDate){
            this.sentDate = sentDate;
            return this;
        }

        public MailBuilder text(String text){
            this.text = text;
            return this;
        }

        public MailBuilder enclosureName(String name){
            this.enclosureName = name;
            return this;
        }

        public MailBuilder filePath(String filePath){
            this.filePath = filePath;
            return this;
        }

        public String getStatus() {
            return status;
        }

        public String getEnclosureName() {
            return enclosureName;
        }

        public void setEnclosureName(String enclosureName) {
            this.enclosureName = enclosureName;
        }

        public void setStatus(String status) {
            this.status = status;
        }

        public String getErr() {
            return err;
        }

        public void setErr(String err) {
            this.err = err;
        }

        public MailDTO build(){
            return new MailDTO(this);
        }

        public String getFrom() {
            return from;
        }

        public void setFrom(String from) {
            this.from = from;
        }

        public String[] getTo() {
            return to;
        }

        public void setTo(String[] to) {
            this.to = to;
        }

        public String getSubject() {
            return subject;
        }

        public void setSubject(String subject) {
            this.subject = subject;
        }

        public String getCc() {
            return cc;
        }

        public void setCc(String cc) {
            this.cc = cc;
        }

        public Date getSentDate() {
            return sentDate;
        }

        public void setSentDate(Date sentDate) {
            this.sentDate = sentDate;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }

        public String getData() {
            return filePath;
        }

        public void setData(String filePath) {
            this.filePath = filePath;
        }
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getErr() {
        return err;
    }

    public void setErr(String err) {
        this.err = err;
    }

    public String getEnclosureName() {
        return enclosureName;
    }

    public void setEnclosureName(String enclosureName) {
        this.enclosureName = enclosureName;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String[] getTo() {
        return to;
    }

    public void setTo(String[] to) {
        this.to = to;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getCc() {
        return cc;
    }

    public void setCc(String cc) {
        this.cc = cc;
    }

    public Date getSentDate() {
        return sentDate;
    }

    public void setSentDate(Date sentDate) {
        this.sentDate = sentDate;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }


    @Override
    public String toString() {
        return "MailDTO{" +
                "from='" + from + '\'' +
                ", to=" + Arrays.toString(to) +
                ", subject='" + subject + '\'' +
                ", cc='" + cc + '\'' +
                ", sentDate=" + sentDate +
                ", text='" + text + '\'' +
                ", enclosureName='" + enclosureName + '\'' +
                ", filePath='" + filePath + '\'' +
                ", status='" + status + '\'' +
                ", err='" + err + '\'' +
                '}';
    }
}
